#!/usr/bin/env python

import unittest

from canvaside.style import *

class TestColor(unittest.TestCase):
    def testParseColor(self):
        self.assertEqual((0, 0, 0, 0), parseColor('transparent'))

        self.assertEqual((170, 187, 204, 255), parseColor('#abc'))
        self.assertEqual((170, 187, 204, 255), parseColor('#aabbcc'))

        self.assertEqual((1, 2, 3, 255), parseColor('rgb(1, 2, 3)'))

        self.assertEqual((1, 2, 3, 77), parseColor('rgba(1, 2, 3, 0.3)'))

        self.assertEqual((255, 128, 77, 255), parseColor('rgb(100%, 50%, 30%)'))
        self.assertEqual((255, 128, 77, 26), parseColor('rgba(100%, 50%, 30%, .1)'))

        self.assertEqual((1, 0, 3, 255), parseColor('rgb(1, -2, 3)'))
        self.assertEqual((255, 128, 0, 255), parseColor('rgb(110%, 50%, -30%)'))

        self.assertEqual((0, 255, 0, 255), parseColor('hsl(120, 100%, 50%)'))
        self.assertEqual((0, 255, 0, 77), parseColor('hsla(120, 100%, 50%, 0.3)'))

if __name__=='__main__':
    unittest.main()